<?php
/*$url = "http://218.76.51.168";
$url = $url . ":8088/V0/GetDept.ashx?";*/
$url = "http://mallcmsapi1.tepin.com/api/DataTransfer/GetDept_Notice";
//$url = "http://mallcmsapi1.tepin.com/api/DataTransfer/GetPerson_Notice";
//$url = "http://mallcmsapi1.tepin.com/api/DataTransfer/GetCategory_Notice";
//$url = "http://mallcmsapi1.tepin.com/api/DataTransfer/GetGoods_Notice";
//$url = "http://mallcmsapi1.tepin.com/api/DataTransfer/GetBrannd_Notice";
//$url = "http://mallcmsapi1.tepin.com/api/DataTransfer/GetStock_Notice";
$url = "http://mallcmsapi1.tepin.com/api/DataTransfer/Data_Update_Notice";
$url = "http://mallcmsadmin1.tepin.com/api/DataTransfer/Data_Update_Notice";
echo "<form action='$url' method=post enctype=multipart/form-data>";
header("Content-type: text/html; charset=UTF-8");
$time = "1536989387";
$sign = "0386e8a3ae0d38edae75df56c5ecb3cd";

echo "a出现的位置：";
echo strpos('abcdef', 'ab');
//
#echo $request;
//
//
//$table_name = "ymall_item";

$table_name = "ymall_erp_group";
$table_name = "ymall_stock";
/*$table_name = "sys_user";
$table_name = "ymall_category";
$table_name = "ymall_item";
$table_name = "ymall_brand";
$table_name = "ymall_stock";*/
$time = time();
$time = "1539581001147";
/* $data[]["sellerPath"] = "68120001";
$data[]["sellerPath"] = "68120002";*/
if ($table_name == 'ymall_erp_group') {
	$data = array(array('sellerPath' => '68120001'),
// array('sellerPath' => '68120002')
	);

} elseif ($table_name == 'sys_user') {
	$data = array(array('rydm' => '20000402'),
		array('rydm' => '10001666'));
} elseif ($table_name == 'ymall_category') {
	$data = array(array('categoryPath' => '020301'),
		array('categoryPath' => '03'),
		array('categoryPath' => '0301'));
} elseif ($table_name == "ymall_item") {
	$data = array(array('sku' => 'KECY2772HS09', 'barcode' => "", 'sellerPath' => '26130001'),
		array('sku' => '183D10330902', 'barcode' => "", 'sellerPath' => '26110001'));
} elseif ($table_name == "ymall_brand") {
	$data = array(array('branndId' => '2838'),
		array('branndId' => '2707'),
		array('branndId' => '3826'));
} elseif ($table_name == 'ymall_stock') {
	$data = array(array('sku' => "KECMY2819-DRD11", 'sellerPath' => '26130001'),
		array('sku' => "KECMY2819-DJT19", 'sellerPath' => '26130001'),
		array('sku' => "2110000458000", 'sellerPath' => '26130001'));

}
#var_dump($data);exit;

$data2 = json_encode($data);
$params = array(
	"partner" => "ERP0001",
	"table_name" => $table_name,
	"TimeStamp" => $time,
	"data" => $data2,
);

foreach ($params as $key => $value) {
	$arr[strtolower($key)] = $key . "=" . $value;

}
ksort($arr);
//排序后，把key换回来
$params = array();
foreach ($arr as $key => $value) {
	$new_arr = explode("=", $value);
	$params[$new_arr[0]] = $new_arr[1];
}
#重新拼接参数1=值1&参数2=值2...用http_build_query()函数有乱码
foreach ($params as $key => $value) {
	$paramstring = isset($paramstring) ? $paramstring . "&" . $key . "=" . $value : $key . "=" . $value;
}
$key = "ERP8888";
echo "<br>paramstring=" . $paramstring;
$sign = md5($paramstring . $key);
echo "<br>sign=" . $sign;

$params2 = array(
	"partner" => "ERP0001",
	"table_name" => $table_name,
	"sign" => $sign,
	"TimeStamp" => $time,
	"data" => $data,

);
$request = json_encode($params2);
echo "<br>---  " . $request;
echo "<input type='hidden' name='request' value=$request>";

echo "     <input type=submit name='sub1' value=test>
         </form> ";
if (isset($_POST['sub1'])) {
	print_r($_POST);

}
